function p = prtbill(sd,md,rv,disc)
%PRTBILL Price of treasury bill.
%   P = PRTBILL(SD,MD,RV,DISC) returns the price for a Treasury bill.
%   SD is the settlement date, MD is the maturity date, RV is the redemption
%   value and DISC is the discount rate. Enter the settlement and maturity
%   dates as serial date numbers or date strings.
%
%   For example, the settlement date of a treasury bill is February 10, 1992,
%   the maturity date is August 6, 1992, the discount rate is 3.77%, and the
%   redemption value is $1000.  The treasury bill price is
%   p = prtbill('2/10/1992', '8/6/1992', 1000, 0.0377)
%   or p = 981.36.
%
%   See also BEYTBILL, YLDTBILL.
%
%   Reference: Bodie, Kane, and Marcus, Investments, pages 41-43.

%       Copyright 1995-2006 The MathWorks, Inc.
%       $Revision: 1.6.2.3 $   $Date: 2009/04/15 23:07:40 $


if nargin < 4
    error('finance:prtbill:missingInputs','Missing one of SD, MD, RV, and DISC.')
end

% Scale up the arguments and set defaults
try
    [~, Settle, Maturity, ~, ~, ~, ~, ~, ~, ~, Face] = ...
        instargbond([],sd,md,[],[],[],[],[],[],[],rv);
    
catch E
    newE = MException('Finance:prtbill:inputError',...
        'Error in Settle, Maturity, or RV Inputs.');
    newE = addCause(newE,E);
    throw(newE)
end

if ~isnumeric(disc)
    error('finance:prtbill:invalidDiscount','Discount rate must be numeric.')
end

% Now match the previous input sizes with discount
try
    [Settle, Maturity, Face, Discount] = finargsz(1, Settle, Maturity, Face, disc);
catch E
    newE = MException('Finance:prtbill:invalidInputSize',...
        'Error in input sizes.');
    newE = addCause(newE,E);
    throw(newE)
end

p = Face.*(1-Discount.*daysact(Settle,Maturity)./360);  % Formula 2.2
